/*
*************************************************************************
*西瑞克斯研发管理系统
*版 本: 1.0   
*日 期：02/11/2012    
*作 者： 王浩 QQ：873987060   
*************************************************************************   
*/ 
package com.manager.workflow.core;

import org.fireflow.engine.EngineException;
import org.fireflow.engine.IProcessInstance;
import org.fireflow.engine.ITaskInstance;
import org.fireflow.engine.IWorkflowSession;
import org.fireflow.engine.RuntimeContext;
import org.fireflow.engine.taskinstance.ITaskInstanceCreator;
import org.fireflow.model.Task;
import org.fireflow.model.net.Activity;

import com.workflowdefinition.YfBussTaskinstance;
/**
 * 扩展工作流任务实例
 * @author 王浩 QQ：873987060   
 *
 */
public class BussTaskInstanceCreator implements ITaskInstanceCreator {

	@Override
	public ITaskInstance createTaskInstance(IWorkflowSession currentSession,RuntimeContext runtimeContxt, IProcessInstance processInstance,Task task, Activity activity)
			throws EngineException {
		System.out.println("  创建任务实例  ==============  ");
		YfBussTaskinstance yfBussTaskinstance = new YfBussTaskinstance();
		String bussId = getValue(processInstance.getProcessInstanceVariable("bussId"));
		String bussType =  getValue(processInstance.getProcessInstanceVariable("bussType"));
		String projectName = getValue(processInstance.getProcessInstanceVariable("projectName"));
		String projectType = getValue(processInstance.getProcessInstanceVariable("projectType"));
		String projectOrg = getValue(processInstance.getProcessInstanceVariable("projectOrg"));
		String projectNo = getValue(processInstance.getProcessInstanceVariable("projectNo"));
		String ownYear = getValue(processInstance.getProcessInstanceVariable("ownYear"));
        Integer bussTaskType = getInt(processInstance.getProcessInstanceVariable("yfbussTaskType"));
		yfBussTaskinstance.setBussId(bussId);
		yfBussTaskinstance.setBussType(Long.valueOf(bussType));
		yfBussTaskinstance.setProjectName(projectName);
		yfBussTaskinstance.setProjectType(projectType);
		yfBussTaskinstance.setProjectOrg(projectOrg);
		yfBussTaskinstance.setProjectNo(projectNo);
		yfBussTaskinstance.setOwnYear(Long.valueOf(ownYear));
		yfBussTaskinstance.setYfbussTaskType((bussTaskType));
		return yfBussTaskinstance;
	}
	public String getValue(Object o){
		if(o==null){
			return "-1";
		}
		return (String) o;
	}
	public int getInt(Object o){
		if(o==null){
			return 1000;
		}
		return (Integer)o;
	}

}
